//package com.mobile_fault_detector.service.impl;
//
//
//import com.mobile_fault_detector.common.Constants;
//import com.mobile_fault_detector.dto.AIResponse;
//import com.mobile_fault_detector.dto.QueryRequest;
//import com.mobile_fault_detector.service.IGetAnswerService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.MediaType;
//import org.springframework.stereotype.Service;
//import org.springframework.web.client.RestTemplate;
//
//@Slf4j
//@Service
//public class IGetAnswerServiceImpl implements IGetAnswerService {
//
//    @Autowired
//    private RestTemplate restTemplate;
//
//    public IGetAnswerServiceImpl() {
//    }
//
//    @Override
//    public AIResponse getAnswer(QueryRequest queryRequest) {
//            // 设置请求头
//            HttpHeaders headers = new HttpHeaders();
//            headers.setContentType(MediaType.APPLICATION_JSON);
//            headers.set("x-api-key", Constants.API_KEY);
//
//            // 创建请求实体
//            HttpEntity<QueryRequest> requestEntity = new HttpEntity<>(queryRequest, headers);
//
//            // 发送POST请求并获取响应
//            return restTemplate.postForObject(Constants.AI_API_URL, requestEntity, AIResponse.class);
//    }
//}